package com.mxx.bu_yang.adapter;

import android.annotation.SuppressLint;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.mxx.bu_yang.R;
import com.mxx.bu_yang.response.MaterialCodeResponse;

import org.jetbrains.annotations.NotNull;

/**
 * 作者：刘江飞
 * 时间：2020/10/14  14:42
 * 邮箱：642371742Z@qq.com
 * 描述：货品批次
 **/
public class CheckResultAdapter extends BaseQuickAdapter<MaterialCodeResponse, BaseViewHolder> {
    public CheckResultAdapter(int layoutResId) {
        super(layoutResId);
        addChildClickViewIds(R.id.tv_name);
    }

    @SuppressLint("SetTextI18n")
    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, MaterialCodeResponse response) {
        if (response == null) {
            return;
        }

        TextView tv_name = baseViewHolder.getView(R.id.tv_name);
        TextView tv_des = baseViewHolder.getView(R.id.tv_des);
        String lotNo = response.lotNo;
        if (lotNo != null) {
            tv_name.setText(lotNo + ":");
        }
        Integer actualQty = response.actualQty;
        if (actualQty == null) {
            actualQty = 0;
        }
        Integer stockQty = response.stockQty;
        if (stockQty == null) {
            stockQty = 0;
        }
        String des;
        if (stockQty >= actualQty) {
            des = "少" + (stockQty - actualQty) + "  " + "-" + "  ";
        } else {
            des = "多" + (actualQty - stockQty) + "  " + "-" + "  ";
        }
        tv_des.setText(des);
    }
}
